#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 3) {
        cout << "Usage: " << argv[0] << " string dict" << endl;
        return 0;
    }

    string str(argv[1]);

    unordered_set<string> dict;
    fstream fs;
    fs.open(argv[2], iostream::in);
    if (!fs.is_open()) {
        cout << "Dict file open error!" << endl;
        return 1;
    }

    string tmp;
    while (fs >> tmp) {
        if (tmp.empty()) {
            break;
        }

        dict.insert(tmp);
    }
    fs.close();

    vector<string> output;
    output = wordBreakAll1(str, dict);
    for (auto it = output.begin(); it != output.end(); it++) {
        cout << *it << endl;
    }

    return 0;
}
